package ycl.common.properties;

import lombok.Data;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import ycl.common.enums.RedisEnum;

import java.util.Set;

/**
 * redis参数
 *
 * @author ycl
 * @date 2022/6/17 0017 16:21:29
 */
@Data
@Component
@ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties {

    private String host = "127.0.0.1";
    private int post = 6379;
    private String password;
    private int timeout = 6000;
    private int maxActive = 100;
    private int maxIdle = 3;
    private int minIdle = 0;
    private int maxWait = -1;

    private Set<DB> dbs;
    private Set<Integer> enableDbs;
    private Set<RedisEnum> redisConfig;

    @Getter
    public enum DB {
        db0(0, true),
        db1(1, false),
        db2(2, false),
        db3(3, false),
        db4(4, false),
        db5(5, false),
        db6(6, false),
        db7(7, false),
        db8(8, false),
        db9(9, false),
        db10(10, false),
        db11(11, false),
        db12(12, false),
        db13(13, false),
        db14(14, false),
        db15(15, false),


        ;

        DB(int num, boolean enable) {
            this.num = num;
            this.enable = enable;
        }

        private final int num;

        private final boolean enable;

    }
}
